package com.sino.androiddesign.design

import android.graphics.Color
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.sino.androiddesign.R
import kotlinx.android.synthetic.main.activity_cat.*

/**
 * CoordinatorLayout和AppbarLayout的配合，以及实现了NestedScrollView的布局或控件。
 */
class CATActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_cat)

        StatusBarUtils.setTranslucentImageHeader(this, 0, cat_toolbar)
        cat_coll_tl.title = ""
        cat_coll_tl.setCollapsedTitleTextColor(Color.GREEN)
        cat_coll_tl.setExpandedTitleColor(Color.YELLOW)
        cat_app_bar.addOnOffsetChangedListener { _, verticalOffset ->
            if (Math.abs(verticalOffset) >= cat_app_bar.totalScrollRange) {
                cat_toolbar.setTitleTextColor(Color.GREEN)
                cat_coll_tl.title = "AppBarLayout"
            } else {

                cat_coll_tl.title = ""
            }
        }

    }
}
